package com.shop.cereshop.commons.config;

import com.huifu.bspay.sdk.opps.core.config.MerConfig;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * 汇付相关参数
 */
@Data
@Component
@ConfigurationProperties(prefix = "huifu")
public class HuifuBaseConfig {

    /**
     * 汇付分配的产品号
     */
    private String productId;

    /**
     * 汇付分配的系统号
     */
    private String sysId;

    /**
     * 服务商私钥，用于调用接口时进行签名
     */
    private String rsaPrivateKey;

    /**
     * 汇付公钥，用于对汇付返回报文进行签名验证
     */
    private String rsaPublicKey;

    /**
     * 获取MerConfig实例
     *
     * @return
     */
    public MerConfig getMerConfig() {
        MerConfig merConfig = new MerConfig();
        merConfig.setProcutId(this.productId);
        merConfig.setSysId(this.sysId);
        merConfig.setRsaPrivateKey(this.rsaPrivateKey);
        merConfig.setRsaPublicKey(this.rsaPublicKey);

        //自定义超时时间
//        merConfig.setCustomSocketTimeout(3000);
//        merConfig.setCustomConnectTimeout(DemoTestConstants.CUSTOM_CONNECT_TIMEOUT);
//        merConfig.setCustomConnectionRequestTimeout(DemoTestConstants.CUSTOM_CONNECTION_REQUEST_TIMEOUT);
        return merConfig;
    }
}
